

**Notes on Correction

***There is a typo in the previous version of the codes. The variable of interest in columns 3 and 4 should be 

***treatyport_ydummy2 rather than treatyports********

****The finding that the population difference is mainly driven by migration from other provinces hold after correcting the typo***


clear all
set memo 100m
capture log close


local filename migration

log using migration, replace text

local output_dir draft
local output_tex1 `filename'.tex


cd "C:\Users\rujia\Dropbox\Replication\treatyports"


use data/migration.dta, clear
qui tabu year, gen(ydummy)
qui tabu id2, gen(idummy)

gen treatyport_ydummy1=treatyports*ydummy1
gen treatyport_ydummy2=treatyports*ydummy2


local fe "idummy* ydummy*" 
label var treatyport_ydummy2 "Treatyports * Year 2000"

label var treatyports "Treaty Ports"

gen ln_movingin_other=log(movingin_other)
gen ln_movingin_own=log(movingin_own)

label var birthrate "Birth Rate"
label var deathrate "Death Rate"
label var  ln_movingin_other "Other Prov."
label var ln_movingin_own "Own"

#delimit ;
eststo clear;

eststo:  regress  birthrate treatyports;
estadd scalar nobs=e(N);


eststo:  regress    birthrate treatyport_ydummy2 `fe';
estadd local fe "Y";
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);

eststo:  regress  deathrate  treatyports;
estadd scalar nobs=e(N);

eststo:  regress    deathrate  treatyport_ydummy2 `fe';
estadd local fe "Y";
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);

esttab using draft/`output_tex1', replace
	width(\hsize) 
	mlabel (, depvar)
	b(3)
	se(3)
	noconstant
	star(* 0.10 ** 0.05 *** 0.01)
	keep(
treatyports
treatyport_ydummy2
)
		
	label
	stats(
		fe
		 nobs
		 rsquare
		, 
		labels(
			"Prefecture and Year FE" 
			"\# observations"
			"R-squared"
			) 
		fmt(0)
		layout(@)
		)
	nonotes
	addnotes(
	)
	;
	
eststo clear;
eststo:  regress  ln_movingin_other treatyports;
estadd scalar nobs=e(N);


eststo:  regress  ln_movingin_other treatyport_ydummy2 `fe';
estadd local fe "Y";
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);


eststo:  regress  ln_movingin_own treatyports;
estadd scalar nobs=e(N);


eststo:  regress  ln_movingin_own treatyport_ydummy2 `fe';
estadd local fe "Y";
estadd scalar nobs=e(N);
estadd scalar rsquare=e(r2);


esttab using draft/`output_tex1', append
	width(\hsize) 
	mlabel (, depvar)
	b(3)
	se(3)
	noconstant
	star(* 0.10 ** 0.05 *** 0.01)
	keep(
treatyports
treatyport_ydummy2
)
		
	label
	stats(
		fe
		 nobs
		 rsquare
		, 
		labels(
			"Prefecture and Year FE" 
			"\# observations"
			"R-squared"
			) 
		fmt(0)
		layout(@)
		)
	nonotes
	;




